<?xml version="1.0"?>
<xsd:schema
   targetNamespace="http://www.opengis.net/wfs"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:wfs="http://www.opengis.net/wfs"
   elementFormDefault="qualified">

   <!-- ==============================================================
        Includes and Imports
        ============================================================== -->
   <xsd:include schemaLocation="WFS-basic.xsd"/>
   <xsd:import namespace="http://www.opengis.net/gml"
               schemaLocation="../../gml/2.1.2/feature.xsd"/>
   <xsd:import namespace="http://www.opengis.net/ogc"
               schemaLocation="../../filter/1.0.0/filter.xsd"/>

   <!-- ==============================================================
         REQUEST MESSAGES
         ============================================================== -->
   <xsd:element name="GetFeatureWithLock" type="wfs:GetFeatureWithLockType">
      <xsd:annotation>
         <xsd:documentation>
            This is the root element for the GetFeatureWithLock request.
            The GetFeatureWithLock operation performs identically to a
            GetFeature request except that the GetFeatureWithLock request
            locks all the feature instances in the result set and returns
            a lock identifier to a client application in the response.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:element name="LockFeature" type="wfs:LockFeatureType">
      <xsd:annotation>
         <xsd:documentation>
            This is the root element for a LockFeature request.
            The LockFeature request can be used to lock one or
            more feature instances.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:element name="Transaction" type="wfs:TransactionType">
      <xsd:annotation>
         <xsd:documentation>
            This is the root element for a Transaction request.
            A transaction request allows insert, update and 
            delete operations to be performed to create, change
            or remove feature instances.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>

   <!-- ==============================================================
         RESPONSE MESSAGES
         ============================================================== -->
   <xsd:element name="WFS_LockFeatureResponse"
                type="wfs:WFS_LockFeatureResponseType">
      <xsd:annotation>
         <xsd:documentation>
            The WFS_LockFeatureResponse element contains a report
            about the completion status of a LockFeature request.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:element name="WFS_TransactionResponse"
                type="wfs:WFS_TransactionResponseType">
      <xsd:annotation>
         <xsd:documentation>
            The WFS_TransactionResponse element contains a report
            about the completion status of a Transaction operation.  
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>

   <!-- ==============================================================
         COMMON ATTRIBUTE DOCUMENTATION
         ============================================================== 
         EXPIRY:
            The expiry attribute value is specified in minutes. It
            indicates how long a Web Feature Service should wait to
            receive a request from the client application that locked
            the feature instances.  If the specified time elapses and
            no request has been received by a Web Feature Service that
            references the lockId given to the client application, then
            the locks maintained by the Web Feature Service shall be
            released and the lockId that references the locked features
            shall now be invalid.  If the expiry attribute is not specified,
            then the feature instances shall be locked indefinitely and the
            intervention of an administrator may be required to release
            the locks. -->

   <!-- ==============================================================
         TYPES
         ============================================================== -->
   <!-- GETFEATUREWITHLOCK -->
   <xsd:complexType name="GetFeatureWithLockType">
      <xsd:annotation>
         <xsd:documentation>
            A GetFeatureWithLock request operates identically to a
            GetFeature request expect that it attempts to lock the
            feature instances in the result set and includes a lock
            identifier in its response to a client.  A lock identifier
            is an identifier generated by a Web Feature Service that 
            a client application can use, in subsequent operations,
            to reference the locked set of feature instances.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element ref="wfs:Query" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
      <xsd:attribute name="service"
                     type="xsd:string" use="required" fixed="WFS"/>
      <xsd:attribute name="handle"
                     type="xsd:string" use="optional"/>
      <xsd:attribute name="expiry"
                     type="xsd:positiveInteger" use="optional"/>
      <xsd:attribute name="outputFormat"
                     type="xsd:string" use="optional" default="GML2"/>
      <xsd:attribute name="maxFeatures"
                     type="xsd:positiveInteger" use="optional"/>
   </xsd:complexType>
   <!-- LOCKFEATURE -->
   <xsd:complexType name="LockFeatureType">
      <xsd:annotation>
         <xsd:documentation>
            This type defines the LockFeature operation.  The LockFeature
            element contains one or more Lock elements that define
            which features of a particular type should be locked.  A lock
            identifier (lockId) is returned to the client application which
            can be used by subsequent operations to reference the locked
            features.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element name="Lock" type="wfs:LockType" maxOccurs="unbounded">
            <xsd:annotation>
               <xsd:documentation>
                  The lock element is used to indicate which feature 
                  instances of particular type are to be locked.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
      <xsd:attribute name="service"
                     type="xsd:string" use="required" fixed="WFS"/>
      <xsd:attribute name="expiry"
                     type="xsd:positiveInteger" use="optional"/>
      <xsd:attribute name="lockAction"
                     type="wfs:AllSomeType" use="optional">
         <xsd:annotation>
            <xsd:documentation>
               The lockAction attribute is used to indicate what
               a Web Feature Service should do when it encounters
               a feature instance that has already been locked by
               another client application.

               Valid values are ALL or SOME.

               ALL means that the Web Feature Service must acquire
               locks on all the requested feature instances.  If it
               cannot acquire those locks then the request should
               fail.  In this instance, all locks acquired by the
               operation should be released.
 
               SOME means that the Web Feature Service should lock
               as many of the requested features as it can.
            </xsd:documentation>
         </xsd:annotation>
      </xsd:attribute>
   </xsd:complexType>
   <xsd:complexType name="LockType">
      <xsd:annotation>
         <xsd:documentation>
            This type defines the Lock element.  The Lock element
            defines a locking operation on feature instances of 
            a single type. An OGC Filter is used to constrain the
            scope of the operation.  Features to be locked can be
            identified individually by using their feature identifier
            or they can be locked by satisfying the spatial and 
            non-spatial constraints defined in the filter.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element ref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
      <xsd:attribute name="handle" 
                     type="xsd:string" use="optional"/>
      <xsd:attribute name="typeName" 
                     type="xsd:QName" use="required"/>
   </xsd:complexType>
   <!-- TRANSACTION -->
   <xsd:complexType name="TransactionType">
      <xsd:annotation>
         <xsd:documentation>
            The TranactionType defines the Transaction operation.  A
            Transaction element contains one or more Insert, Update
            Delete and Native elements that allow a client application
            to create, modify or remove feature instances from the 
            feature repository that a Web Feature Service controls.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element ref="wfs:LockId" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  In order for a client application to operate upon locked
                  feature instances, the Transaction request must include
                  the LockId element.  The content of this element must be
                  the lock identifier the client application obtained from
                  a previous GetFeatureWithLock or LockFeature operation.

                  If the correct lock identifier is specified the Web
                  Feature Service knows that the client application may
                  operate upon the locked feature instances.

                  No LockId element needs to be specified to operate upon
                  unlocked features.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element ref="wfs:Insert"/>
            <xsd:element ref="wfs:Update"/>
            <xsd:element ref="wfs:Delete"/>
            <xsd:element ref="wfs:Native"/>
         </xsd:choice>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
      <xsd:attribute name="service"
                     type="xsd:string" use="required" fixed="WFS"/>
      <xsd:attribute name="handle"
                     type="xsd:string" use="optional"/>
      <xsd:attribute name="releaseAction"
                     type="wfs:AllSomeType" use="optional">
         <xsd:annotation>
            <xsd:documentation>
               The releaseAction attribute is used to control how a Web
               Feature service releases locks on feature instances after
               a Transaction request has been processed.

               Valid values are ALL or SOME.

               A value of ALL means that the Web Feature Service should
               release the locks of all feature instances locked with the
               specified lockId, regardless or whether or not the features
               were actually modified.

               A value of SOME means that the Web Feature Service will 
               only release the locks held on feature instances that 
               were actually operated upon by the transaction.  The lockId
               that the client application obtained shall remain valid and
               the other, unmodified, feature instances shall remain locked.
               If the expiry attribute was specified in the original operation 
               that locked the feature instances, then the expiry counter
               will be reset to give the client application that same amount
               of time to post subsequent transactions against the locked
               features.
            </xsd:documentation>
         </xsd:annotation>
      </xsd:attribute>
   </xsd:complexType>
   <xsd:element name="LockId" type="xsd:string">
      <xsd:annotation>
         <xsd:documentation>
            The LockId element contains the value of the lock identifier
            obtained by a client application from a previous GetFeatureWithLock
            or LockFeature request.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:element name="Insert" type="wfs:InsertElementType">
      <xsd:annotation>
         <xsd:documentation>
            The Insert element is used to indicate that the Web Feature
            Service should create a new instance of a feature type.  The
            feature instance is specified using GML2 and one or more 
            feature instances to be created can be contained inside the
            Insert element.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:complexType name="InsertElementType">
      <xsd:sequence>
         <xsd:element ref="gml:_Feature" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
   </xsd:complexType>
   <xsd:element name="Update" type="wfs:UpdateElementType">
      <xsd:annotation>
         <xsd:documentation>
            One or more existing feature instances can be changed by
            using the Update element.  Changing a feature instance
            means that the current value of one or more properties of
            the feature are replaced with new values.  The Update
            element contains  one or more Property elements.  A
            Property element contains the name or a feature property
            who's value is to be changed and the replacement value
            for that property.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:complexType name="UpdateElementType">
      <xsd:sequence>
         <xsd:element ref="wfs:Property" maxOccurs="unbounded" />
         <xsd:element ref="ogc:Filter" minOccurs="0" maxOccurs="1">
            <xsd:annotation>
               <xsd:documentation>
                  The Filter element is used to constrain the scope
                  of the update operation to those features identified
                  by the filter.  Feature instances can be specified
                  explicitly and individually using the identifier of
                  each feature instance OR a set of features to be
                  operated on can be identified by specifying spatial
                  and non-spatial constraints in the filter.
                  If no filter is specified, then the update operation 
                  applies to all feature instances.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
      <xsd:attribute name="typeName" type="xsd:QName" use="required"/>
   </xsd:complexType>
   <xsd:element name="Delete" type="wfs:DeleteElementType">
      <xsd:annotation>
         <xsd:documentation>
            The Delete element is used to indicate that one or more
            feature instances should be removed from the feature
            repository.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:complexType name="DeleteElementType">
      <xsd:sequence>
         <xsd:element ref="ogc:Filter" minOccurs="1" maxOccurs="1">
            <xsd:annotation>
               <xsd:documentation>
                  The Filter element is used to constrain the scope
                  of the delete operation to those features identified
                  by the filter.  Feature instances can be specified
                  explicitly and individually using the identifier of
                  each feature instance OR a set of features to be
                  operated on can be identified by specifying spatial
                  and non-spatial constraints in the filter.
                  If no filter is specified then an exception should
                  be raised since it is unlikely that a client application
                  intends to delete all feature instances.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
      <xsd:attribute name="typeName" type="xsd:QName" use="required"/>
   </xsd:complexType>
   <xsd:element name="Native" type="wfs:NativeType">
      <xsd:annotation>
         <xsd:documentation>
            Many times, a Web Feature Service interacts with a repository
            that may have special vendor specific capabilities.  The native
            element allows vendor specific command to be passed to the
            repository via the Web Feature Service.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:complexType name="NativeType">
      <xsd:attribute name="vendorId" type="xsd:string" use="required">
         <xsd:annotation>
            <xsd:documentation>
               The vendorId attribute is used to specify the name of
               vendor who's vendor specific command the client
               application wishes to execute.
            </xsd:documentation>
         </xsd:annotation>
      </xsd:attribute>
      <xsd:attribute name="safeToIgnore" type="xsd:boolean" use="required">
         <xsd:annotation>
            <xsd:documentation>
               In the event that a Web Feature Service does not recognize
               the vendorId or does not recognize the vendor specific command,
               the safeToIgnore attribute is used to indicate whether the 
               exception can be safely ignored.  A value of TRUE means that
               the Web Feature Service may ignore the command.  A value of
               FALSE means that a Web Feature Service cannot ignore the
               command and an exception should be raised if a problem is 
               encountered.
            </xsd:documentation>
         </xsd:annotation>
      </xsd:attribute>
   </xsd:complexType>

   <!-- define structure to specify a property value -->
   <xsd:element name="Property" type="wfs:PropertyType">
      <xsd:annotation>
         <xsd:documentation>
            The Property element is used to specify the new
            value of a feature property inside an Update element.
         </xsd:documentation>
      </xsd:annotation>
   </xsd:element>
   <xsd:complexType name="PropertyType">
      <xsd:sequence>
         <xsd:element name="Name" type="xsd:string">
            <xsd:annotation>
               <xsd:documentation>
                  The Name element contains the name of a feature property
                  to be updated.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="Value" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  The Value element contains the replacement value for the
                  named property.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
   <!-- RESPONSE TYPES -->
   <xsd:complexType name="WFS_LockFeatureResponseType">
      <xsd:annotation>
         <xsd:documentation>
            The WFS_LockFeatureResponseType is used to define an
            element to contains the response to a LockFeature
            operation.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element ref="wfs:LockId">
            <xsd:annotation>
               <xsd:documentation>
                  The WFS_LockFeatureResponse includes a LockId element
                  that contains a lock identifier.  The lock identifier
                  can be used by a client, in subsequent operations, to
                  operate upon the locked feature instances.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="FeaturesLocked"
                      type="wfs:FeaturesLockedType" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  The LockFeature or GetFeatureWithLock operations
                  identify and attempt to lock a set of feature 
                  instances that satisfy the constraints specified 
                  in the request.  In the event that the lockAction
                  attribute (on the LockFeature or GetFeatureWithLock
                  elements) is set to SOME, a Web Feature Service will
                  attempt to lock as many of the feature instances from
                  the result set as possible.

                  The FeaturesLocked element contains list of ogc:FeatureId
                  elements enumerating the feature instances that a WFS
                  actually managed to lock.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="FeaturesNotLocked"
                      type="wfs:FeaturesNotLockedType" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  In contrast to the FeaturesLocked element, the
                  FeaturesNotLocked element contains a list of 
                  ogc:Filter elements identifying feature instances
                  that a WFS did not manage to lock because they were
                  already locked by another process.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="FeaturesLockedType">
     <xsd:sequence maxOccurs="unbounded">
       <xsd:element ref="ogc:FeatureId"/>
     </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="FeaturesNotLockedType">
     <xsd:sequence maxOccurs="unbounded">
       <xsd:element ref="ogc:FeatureId"/>
     </xsd:sequence>
   </xsd:complexType>
   <xsd:complexType name="WFS_TransactionResponseType">
      <xsd:annotation>
         <xsd:documentation>
            The WFS_TransactionResponseType defines the format of
            the XML document that a Web Feature Service generates 
            in response to a Transaction request.  The response 
            includes the completion status of the transaction 
            and the feature identifiers of any newly created
            feature instances.
         </xsd:documentation>
      </xsd:annotation>
      <xsd:sequence>
         <xsd:element name="InsertResult"
                      type="wfs:InsertResultType"
                      minOccurs="0" maxOccurs="unbounded">
            <xsd:annotation>
               <xsd:documentation>
                  The InsertResult element contains a list of ogc:FeatureId
                  elements that identify any newly created feature instances.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="TransactionResult"
                      type="wfs:TransactionResultType">
            <xsd:annotation>
               <xsd:documentation>
                  The TransactionResult element contains a Status element
                  indicating the completion status of a transaction.  In
                  the event that the transaction fails, additional element
                  may be included to help locate which part of the transaction
                  failed and why.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="version"
                     type="xsd:string" use="required" fixed="1.0.0"/>
   </xsd:complexType>
   <xsd:complexType name="TransactionResultType">
      <xsd:sequence>
         <xsd:element name="Status" type="wfs:StatusType">
            <xsd:annotation>
               <xsd:documentation>
                  The Status element contains an element indicating the
                  completion status of a transaction.  The SUCCESS element
                  is used to indicate successful completion.  The FAILED
                  element is used to indicate that an exception was 
                  encountered.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="Locator" type="xsd:string" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  In the event that an exception was encountered while 
                  processing a transaction, a Web Feature Service may
                  use the Locator element to try and identify the part
                  of the transaction that failed.  If the element(s)
                  contained in a Transaction element included a handle
                  attribute, then a Web Feature Service may report the
                  handle to identify the offending element.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
         <xsd:element name="Message" type="xsd:string" minOccurs="0">
            <xsd:annotation>
               <xsd:documentation>
                  The Message element may contain an exception report
                  generated by a Web Feature Service when an exception
                  is encountered.
               </xsd:documentation>
            </xsd:annotation>
         </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
   </xsd:complexType>
   <xsd:complexType name="InsertResultType">
      <xsd:sequence>
         <xsd:element ref="ogc:FeatureId" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="handle" type="xsd:string" use="optional"/>
   </xsd:complexType>
   <xsd:complexType name="StatusType">
      <xsd:choice>
         <xsd:element ref="wfs:SUCCESS"/>
         <xsd:element ref="wfs:FAILED"/>
         <xsd:element ref="wfs:PARTIAL"/>
      </xsd:choice>
   </xsd:complexType>
   <xsd:element name="SUCCESS" type="wfs:EmptyType"/>
   <xsd:element name="FAILED" type="wfs:EmptyType"/>
   <xsd:element name="PARTIAL" type="wfs:EmptyType"/>
   <!-- MISC TYPES -->
   <xsd:complexType name="EmptyType"/>
   <xsd:simpleType name="AllSomeType">
      <xsd:restriction base="xsd:string">
         <xsd:enumeration value="ALL"/>
         <xsd:enumeration value="SOME"/>
      </xsd:restriction>
   </xsd:simpleType>
</xsd:schema>
